﻿//Base class for application viewmodels
(function (winjs) {
    "use strict";

    var ViewModelBase = WinJS.Class.define(null,
    {
        processAll: function () {
            for (var prop in this) {
                if (prop !== 'processAll' && prop !== 'constructor' && prop !== 'watch') {
                    if (typeof(this[prop]) === 'function') {
                        var newProp = this[prop].bind(this);
                        newProp.supportedForProcessing = true;
                        this[prop] = newProp;
                    }
                }
            }
        },
        watch: function (object, property, notifyCallback) {
            if (object.bind == undefined) throw "Provided object is not observable";
            object.bind(property, notifyCallback);
        },
        onAppResuming: function () {
            //Override this method inside viewmodel to have it invoked when app resumes
        }
    });

    winjs.Namespace.define("MvvmStack", {
        ViewModelBase: ViewModelBase
    });

})(WinJS)